/*
 * Copyright (C) 2012 Yichao
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package action;

import com.opensymphony.xwork2.ActionSupport;
import ezcms.dto.Conference;
import ezcms.dto.Event;
import ezcms.dto.Topic;
import ezcms.exceptions.PresentationException;
import ezcms.exceptions.ServiceInvokeException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import service.ConferenceService;

/**
 *
 * @author Yichao
 * @author Le Tuan Anh <anh.takaji@gmail.com>
 */
public class ClientConferenceAction extends ActionSupport {

    private long id;
    private Conference conference;
    private List<Conference> conferences;
    private ConferenceService service;
    private Topic topic;
    private Event event;

    public ClientConferenceAction() throws PresentationException {
        this.service = new ConferenceService();
    }

    public String show() {
        try {
            Conference conference = service.getConferenceDelegate().getConferenceById(getId());
            if (conference == null) {
                return "gohome";
            } else {
                setConference(conference);
            }
        } catch (ServiceInvokeException ex) {
            // Cannot retrieve conference -> go home
            return "gohome";
        }
        System.out.println(conference.getEvents());
        return "show";
    }

    /**
     * @return the id
     */
    public long getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(long id) {
        this.id = id;
    }

    public void setId(String id) {
        this.id = Long.parseLong(id);
    }

    /**
     * @return the conference
     */
    public Conference getConference() {
        return conference;
    }

    /**
     * @param conference the conference to set
     */
    public void setConference(Conference conference) {
        this.conference = conference;
    }

    /**
     * @return the conferences
     */
    public List<Conference> getConferences() {
        return conferences;
    }

    /**
     * @param conferences the conferences to set
     */
    public void setConferences(List<Conference> conferences) {
        this.conferences = conferences;
    }

    /**
     * @return the service
     */
    public ConferenceService getService() {
        return service;
    }

    /**
     * @param service the service to set
     */
    public void setService(ConferenceService service) {
        this.service = service;
    }

    /**
     * @return the topic
     */
    public Topic getTopic() {
        return topic;
    }

    /**
     * @param topic the topic to set
     */
    public void setTopic(Topic topic) {
        this.topic = topic;
    }

    /**
     * @return the event
     */
    public Event getEvent() {
        return event;
    }

    /**
     * @param event the event to set
     */
    public void setEvent(Event event) {
        this.event = event;
    }
}
